package com.chenxiao.Memento;

/**
 * @Author: CX
 * @Date: Created in  2024/04/03 15:08
 * @version: v1.0
 * @Description: TODO
 **/
public class app {
    public static void main(String[] args) {

        Originator originator = new Originator();
        originator.setState("State 1");

        // 保存状态
        Memento memento = originator.createMemento();

        // 修改状态
        originator.setState("State 2");

        // 恢复状态
        originator.restoreMemento(memento);

        // 输出状态，应为"State 1"
        System.out.println(originator.getState());
    }
}
